//
//  YWUseMethodAndRangeCell.m
//  maintain
//
//  Created by Kyo on 16/11/2.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWUseMethodAndRangeCell.h"
#import "UIColor+CustomColors.h"
#import "Masonry.h"
#import "YWMacro.h"

@interface YWUseMethodAndRangeCell()
@property (nonatomic, strong) UILabel * greedLabel;
@property (nonatomic, strong) UILabel * headLabel;
@property (nonatomic, strong) UILabel * contentLabel;
@end

@implementation YWUseMethodAndRangeCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.layer.shouldRasterize = YES;
        self.layer.rasterizationScale = [UIScreen mainScreen].scale;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpSubviews];
    }
    
    return self;
}

- (void)setTitle:(NSString *)title{
    _title = title;
    self.headLabel.text = title;
}

- (void)setContent:(NSString *)content{
    _content = content;
    self.contentLabel.text = content;
}

- (void)setUpSubviews{
    UIView *superView = self.contentView;
    [self.greedLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.and.left.mas_equalTo(superView).offset(13);
        make.width.mas_equalTo(12);
        make.height.mas_equalTo(12);
    }];
    [self.headLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(superView.mas_top).offset(10);
        make.left.mas_equalTo(_greedLabel.mas_right).offset(10);
        make.right.mas_equalTo(superView.mas_right).offset(-10);
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_headLabel.mas_bottom).offset(6);
        make.left.mas_equalTo(_headLabel.mas_left);
        make.right.mas_equalTo(_headLabel.mas_right);
        make.bottom.mas_equalTo(superView.mas_bottom).offset(-10);
    }];
}

- (UILabel *)greedLabel{
    if (!_greedLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.backgroundColor = [UIColor customGreenColor];
        label.clipsToBounds = YES;
        label.layer.cornerRadius = 12/2;
        [self.contentView addSubview:label];
        _greedLabel = label;
    }
    return _greedLabel;
}

- (UILabel *)headLabel{
    if (!_headLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.font = kBoldContentFont;
        label.numberOfLines = 0;
        [self.contentView addSubview:label];
        _headLabel = label;
    }
    return _headLabel;
}

- (UILabel *)contentLabel{
    if (!_contentLabel) {
        UILabel *label = [[UILabel alloc] init];
        label.font = kContentFont;
        label.numberOfLines = 0;
        [self.contentView addSubview:label];
        _contentLabel = label;
    }
    return _contentLabel;
}

@end
